import {createStore,compose, applyMiddleware} from 'redux'
import reducers from './reducer'  // 合并
import thunk, {ThunkMiddleware} from 'redux-thunk'
// window interface __REDUX_DEVTOOLS_EXTENSION_COMPOSE__
// ts as 强制类型申明 断言
const composeEnhancers = 
    (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store  = createStore(reducers,
    composeEnhancers(
        applyMiddleware(
            // 断言 dispath    异步action ts-> ThunkMiddleware
            thunk as ThunkMiddleware
            )
        )
    )

// rootState state 状态类型
// type interface ts 里的类型申明
// type 自定义类型
export type rootState = ReturnType<typeof reducers>

export default store